{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\myogo\Princeton Dropbox\Motohiro Yogo\Koijen Yogo - International\JPE\Replication\Code\1 Data\Data0.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res}31 Oct 2025, 09:17:31
{txt}
{com}. /* Load IMF IFS data */
> 
> u year country fx NCP_R_XDC
>         using IMF_IFS, clear;
{txt}
{com}. /* Merge World Bank data */
> 
> merge 1:1 year country using WorldBank,
>         keepusing(outstand cpi consR gdp gdpP gdpPpc PANUSPPP pop)
>         nogen;
{res}
{txt}{col 5}Result{col 33}Number of obs
{col 5}{hline 41}
{col 5}Not matched{col 30}{res}           1,400
{txt}{col 9}from master{col 30}{res}             140{txt}  
{col 9}from using{col 30}{res}           1,260{txt}  

{col 5}Matched{col 30}{res}           4,060{txt}  
{col 5}{hline 41}

{com}. /* Merge Capital IQ Ratings data */
> 
> merge 1:1 year country using Ratings,
>         keepusing(rating drate)
>         nogen;
{res}
{txt}{col 5}Result{col 33}Number of obs
{col 5}{hline 41}
{col 5}Not matched{col 30}{res}           4,619
{txt}{col 9}from master{col 30}{res}           4,619{txt}  
{col 9}from using{col 30}{res}               0{txt}  

{col 5}Matched{col 30}{res}             841{txt}  
{col 5}{hline 41}

{com}. /* Merge Datastream data */
> 
> merge 1:1 year country using Datastream,
>         keepusing(IR3M IR10Y vol retIR3M retMS)
>         nogen;
{res}
{txt}{col 5}Result{col 33}Number of obs
{col 5}{hline 41}
{col 5}Not matched{col 30}{res}           4,529
{txt}{col 9}from master{col 30}{res}           4,529{txt}  
{col 9}from using{col 30}{res}               0{txt}  

{col 5}Matched{col 30}{res}             931{txt}  
{col 5}{hline 41}

{com}. /* Merge MSCI data */
> 
> merge 1:1 year country using MSCI,
>         nogen;
{res}
{txt}{col 5}Result{col 33}Number of obs
{col 5}{hline 41}
{col 5}Not matched{col 30}{res}           4,578
{txt}{col 9}from master{col 30}{res}           4,578{txt}  
{col 9}from using{col 30}{res}               0{txt}  

{col 5}Matched{col 30}{res}             882{txt}  
{col 5}{hline 41}

{com}. /* Merge country code */
> 
> merge m:1 country using Countries,
>         keepusing(Name MSCI Yeuro Ynat)
>         nogen keep(match);
{res}
{txt}{col 5}Result{col 33}Number of obs
{col 5}{hline 41}
{col 5}Not matched{col 30}{res}               0
{txt}{col 5}Matched{col 30}{res}           4,420{txt}  
{col 5}{hline 41}

{com}. /* Construct variables */
> 
> gen Counterpart = country;
{txt}
{com}. gen counterpart = country;
{txt}
{com}. gen byte Ieuro = year>=Yeuro;
{txt}
{com}. drop Yeuro;
{txt}
{com}. /* Construct relative price */
> 
> egen PANUSPPP1 = total(PANUSPPP*gdp*Ieuro) if !missing(PANUSPPP), missing by(year);
{txt}(533 missing values generated)

{com}. egen PANUSPPP2 = total(gdp*Ieuro) if !missing(PANUSPPP), missing by(year);
{txt}(533 missing values generated)

{com}. gen relpi = PANUSPPP;
{txt}(533 missing values generated)

{com}. replace relpi = PANUSPPP1/PANUSPPP2 if Ieuro;
{txt}(322 real changes made)

{com}.         /* GDP-weighted average for euro area */
> 
> replace relpi = PANUSPPP1/PANUSPPP2 if country=="DNK";
{txt}(20 real changes made)

{com}.         /* Denmark pegged to euro */
> replace relpi = 1 if country=="HKG";
{txt}(20 real changes made)

{com}.                                         /* Hong Kong pegged to USD */
> 
> drop PANUSPPP*;
{txt}
{com}. /* Construct real exchange rate */
> 
> gen realfx = fx/relpi;
{txt}(712 missing values generated)

{com}. /* Construct interest rates */
> 
> gen yieldST = ln(1+IR3M);
{txt}(3,519 missing values generated)

{com}. gen yieldLT = ln(1+IR10Y);
{txt}(3,550 missing values generated)

{com}. drop IR3M IR10Y;
{txt}
{com}. /* Construct growth rates */
> 
> sort country year;
{txt}
{com}. foreach var of varlist cpi  {c -(};
{txt}  2{com}.         by country: gen G`var' = ln(`var'/`var'[_n-1]);
{txt}  3{com}.         label var G`var' "Log growth rate of `var'";
{txt}  4{com}. {c )-};
{txt}(972 missing values generated)

{com}. /* Construct future growth rates */
> 
> foreach var of varlist fx NCP_R_XDC cpi consR pop {c -(};
{txt}  2{com}.         by country: gen _G`var' = ln(`var'[_n+1]/`var');
{txt}  3{com}.         label var _G`var' "Future: Log growth rate of `var'";
{txt}  4{com}. {c )-};
{txt}(639 missing values generated)
(2,268 missing values generated)
(972 missing values generated)
(1,440 missing values generated)
(354 missing values generated)

{com}. /* Construct macro variables */
> 
> gen _GconsRpc = _GconsR-_Gpop;
{txt}(1,440 missing values generated)

{com}.                                                                 /* World Bank */
> replace _GconsRpc = _GNCP_R_XDC-_Gpop if missing(_GconsR);
{txt}(75 real changes made)

{com}.         /* IMF IFS */
> 
> /* Construct future returns */
> 
> foreach var of varlist retIR3M retMS {c -(};
{txt}  2{com}.         by country: gen _`var' = `var'[_n+1];
{txt}  3{com}. {c )-};
{txt}(3,525 missing values generated)
(3,489 missing values generated)

{com}. /* Keep sample of countries */
> 
> keep if year>=Ynat;
{txt}(3,712 observations deleted)

{com}. drop Ynat;
{txt}
{com}. /* Label variables */
> 
> order year country Counterpart counterpart Name MSCI Ieuro;
{txt}
{com}. order relpi realfx, after(fx);
{txt}
{com}. label var Counterpart   "Issuer country by residency";
{txt}
{com}. label var counterpart   "Issuer country by nationality";
{txt}
{com}. label var Ieuro                 "Dummy: Euro area";
{txt}
{com}. label var relpi                 "Relative price index (US$ per LCU)";
{txt}
{com}. label var realfx                "Real exchange rate (fx/relpi)";
{txt}
{com}. label var yieldST               "3-month interbank rate (continuously compounded)";
{txt}
{com}. label var yieldLT               "10-year benchmark government yield (continuously compounded)";
{txt}
{com}. label var _GconsRpc             "Future: Log growth rate of real consumption per capita";
{txt}
{com}. label var _retIR3M              "Future: Interest rate (LCU, continuously compounded)";
{txt}
{com}. label var _retMS                "Future: Stock return (US$, continuously compounded)";
{txt}
{com}. /* Save data */
> 
> sort year country;
{txt}
{com}. save Data0, replace;
{txt}{p 0 4 2}
file {bf}
Data0.dta{rm}
saved
{p_end}

{com}. log close;
      {txt}name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\myogo\Princeton Dropbox\Motohiro Yogo\Koijen Yogo - International\JPE\Replication\Code\1 Data\Data0.smcl
  {txt}log type:  {res}smcl
 {txt}closed on:  {res}31 Oct 2025, 09:17:31
{txt}{.-}
{smcl}
{txt}{sf}{ul off}